<template>
  <div>
    <TitleCard
      :title="title"
      :loading="loading"
      :isEmpty="isEmpty"
      :type="'firstCard'"
      @moreClick="toRouter('TechnicalTeam')"
    >
      <div class="searchCard">
        <TableCard :tableList="talentList" @moreChange="moreChange"></TableCard>
      </div>
    </TitleCard>
  </div>
</template>

<script>
import TableCard from '@/components/common/tableCard'
import { getTeamDataList } from '@/api/MTalentData.js'
export default {
  props: {
    title: {
      default: '技术团队',
      type: String
    }
  },
  data() {
    return {
      talentList: [],
      loading: false,
      isEmpty: false
    }
  },
  components: {
    TableCard
  },
  mounted() {
    this.loadData()
  },
  methods: {
    toRouter(router, params) {
      this.$router.push({ name: router, query: { ...params } })
    },
    // 加载数据
    async loadData() {
      try {
        this.loading = true
        let params = {
          status: 1,
          pageNum: 1,
          pageSize: 3
        }
        const data1 = await getTeamDataList(params)
        this.loading = false
        this.talentList = data1.rows

        this.talentList.forEach(item => {
          item.img = this.getUrl(item)
        })
        this.isEmpty = this.talentList.length === 0
      } catch (error) {
        console.log(error)
      } finally {
        this.loading = false
      }
    },
    // 跳转详情
    toDetail(uid) {
      this.$router.push({ name: 'talentDetail', query: { uid } })
    },
    getUrl(item) {
      if (item.fileVo !== null && item.fileVo.length > 0) {
        return item.fileVo[0].filePath
      } else {
        return ''
      }
    },
    moreChange(val) {
      this.$router.push({ name: 'TechnicalTeamDetail', query: { id: val.id } })
    }
  }
}
</script>
